package cn.cxion.chat.app.view;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.makeramen.roundedimageview.RoundedImageView;

import butterknife.Bind;
import butterknife.ButterKnife;
import cn.cxion.chat.R;
import cn.cxion.chat.app.activity.CheckContractActivity;
import cn.cxion.chat.app.bean.CheckContractBean;
import cn.cxion.chat.app.bean.OnHandInfo;
import cn.cxion.chat.app.constant.Constant;

public class OnHandItemView {


    private View view;
    private ViewHolder holder;

    public OnHandItemView(Context context) {
        view = View.inflate(context, R.layout.itemview_onhand, null);

    }

    public View getView() {
        return view;
    }


    public void bindView(CheckContractBean bean) {
        OnHandInfo info=bean.getOnHandInfo();
        holder = new ViewHolder(view);
        holder.tv1.setText(info.getT1());
        holder.tv2.setText(info.getT2());
        holder.tv3.setText(info.getT3());
        holder.tvTime.setText(info.getTime());
        if (info.getState() == 0) {
            holder.imgState.setImageResource(R.drawable.vector_onhand_itemtype1);
        } else if (info.getState() == 1) {
            holder.imgState.setImageResource(R.drawable.vector_onhand_itemtype2);
        } else {
            holder.imgState.setImageResource(R.drawable.vector_onhand_itemtype3);
        }
        holder.llHold.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CheckContractActivity.show(v.getContext(), Constant.CHECKCONTRACT,bean);
            }
        });
    }

    static class ViewHolder {
        @Bind(R.id.img_photo)
        RoundedImageView imgPhoto;
        @Bind(R.id.img_state)
        ImageView imgState;
        @Bind(R.id.tv1)
        TextView tv1;
        @Bind(R.id.tv2)
        TextView tv2;
        @Bind(R.id.tv3)
        TextView tv3;
        @Bind(R.id.tv_time)
        TextView tvTime;
        @Bind(R.id.ll_hold)
        LinearLayout llHold;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
